package com.tjrac.generalpermissions.filter;

import com.tjrac.filter.aspect.HandlerInterceptor;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.PrintWriter;

/**
 * MyFilter
 *
 * @author : xziying
 * @create : 2020-11-29 21:52
 */
public class MyFilter extends HandlerInterceptor {

    /**
     * 权限为空时处理
     */
    @Override
    public void permissionIsEmpty(HttpServletRequest request, HttpServletResponse response) throws Exception {
        request.getRequestDispatcher("/error/nologin.html").forward(request, response);
        //response.sendRedirect("/error/nologin.html");
    }

    /**
     * 权限不通过时处理
     */
    @Override
    public void handler(HttpServletRequest request, HttpServletResponse response) throws Exception {
        request.getRequestDispatcher("/error/inaccessible.html").forward(request, response);
        //response.sendRedirect("/error/inaccessible.html");
    }
}
